package com.acwing.partition18;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/2/7 20:46
 */
public class AC1726挤奶顺序 {

    private static final int N = 110;
    //nums存储相对顺序，seq[i]存储牛i必须要在的顺序
    private static int[] nums = new int[N], seq = new int[N];
    private static boolean[] st = new boolean[N];

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int n = Integer.parseInt(ss[0]), m = Integer.parseInt(ss[1]), k = Integer.parseInt(ss[2]);
        boolean flag = false;
        ss = reader.readLine().split(" ");
        for (int i = 1; i <= m; i++) {
            int a = Integer.parseInt(ss[i - 1]);
            nums[i] = a;
            if (nums[i] == 1) flag = true;
        }
        Arrays.fill(seq, -1);
        nums[0] = 0;
        nums[n + 1] = n + 1;
        for (int i = 0; i < k; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            //如果直接指明了牛1的位置，直接输出
            if (a == 1) {
                writer.write(b + "\n");
                writer.flush();
                return;
            }
            seq[a] = b;
            st[b] = true;
        }
        if (flag) {
            //1在相对位置里面，根据相对位置，尽量把相对位置都往前方
            for (int i = 1, j = 1; i <= m; i++) {
                //如果这个位置已经确定，就继续查看下一个位置
                while (st[j]) j++;
                //如果当前位置已经确定有牛了，就把指针移动到这个确定的位置
                if (seq[nums[i]] != -1) j = seq[nums[i]];
                else {
                    if (nums[i] == 1) {
                        writer.write(j + "\n");
                        writer.flush();
                        return;
                    }
                    st[j++] = true;
                }
            }
        } else {
            //1没在相对位置里面，将相对位置从后往前放，尽量靠后，最后从前往后遍历，有空位就是1的位置
            for (int i = m, j = n; i > 0; i--) {
                while (st[j]) j--;
                if (seq[nums[i]] != -1) j = seq[nums[i]];
                else st[j--] = true;
            }
            for (int i = 1; i <= n; i++) {
                if (!st[i]) {
                    writer.write(i + "\n");
                    writer.flush();
                    return;
                }
            }
        }
        writer.flush();
    }
}
